using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Deduplicator
{
    public partial class Form1 : Form
    {
        private ResourceFileReader resourceFileReader;

        string cRootFolder = "C:\\";
        string cDestinationFolder = "C:\\";

        public Form1()
        {
            InitializeComponent();
            resourceFileReader = new ResourceFileReader(label3, label4, label8, progressBar1, pictureBox1, treeView1);
        }

        public void PerformScan(TreeNode Node)
        {
            if (Node.Checked)
                resourceFileReader.ScanDirectory(Node);

            foreach (TreeNode node in Node.Nodes)
                PerformScan(node);
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
             DialogResult result = folderBrowserDialog1.ShowDialog();
             if (result == DialogResult.OK)
             {
                 cRootFolder = folderBrowserDialog1.SelectedPath;
                 label8.Text = cRootFolder + " selected as root folder"; 
             }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            DialogResult result = folderBrowserDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                cDestinationFolder = folderBrowserDialog1.SelectedPath;
                label8.Text = cRootFolder + " selected as destination folder";
            }
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            resourceFileReader.CountFiles(treeView1.Nodes.Add(cRootFolder, cRootFolder));
            resourceFileReader.filesDone = 0;
            resourceFileReader.SelectedItems = checkedListBox1.SelectedItems;
            MessageBox.Show("Ready.");        
        }

        private void button2_Click(object sender, EventArgs e)
        {
            PerformScan(treeView1.Nodes[0]);
            resourceFileReader.CopyFiles(cDestinationFolder);
            MessageBox.Show("Ready.");            
        }


    }
}